package com.freewater.springboot.demo.ioc.javabasedconfig.returninterfacetype;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

@Configuration
public class AppConfig {

    // 由于OrderManager引用的是TransferServiceImpl，而此@Bean被@Lazy，那么容器就找不到类型为TransferServiceImpl的bean，OrderManager构建报错。
    // 如果去掉@Lazy那么容器实例化此bean后，容器中就会存在类型为TransferServiceImpl的bean，因此OrderManager会注入成功
    @Bean
    @Lazy
    public TransferService transferService() {
        return new TransferServiceImpl();
    }

    @Bean
    public OrderManager orderManager() {
        return new OrderManager();
    }
}
